<?php
    $comum = addslashes($_GET['comum']);
?>
<html  lang="pt-br">
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" type="visao/css/image/x-icon" href="imagens/favicon1.ico" />
<link rel="stylesheet" href="/visao/css/estilo.css" type="text/css" media="all" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="visao/js/jquery-1.2.6.pack.js" type="text/javascript"></script>
<script src="visao/js/jquery.maskedinput-1.1.4.pack.js" type="text/javascript" ></script>
    <script type="text/javascript">$(document).ready(function(){
        $("#linha").focus();
        $('.relatorio tbody tr').hover(				
            function(){$(this).css("background","#C0C0C0");},
            function(){$(this).css("background","");}
        );

    });</script>

<style type="text/css">
<!--
.style1 {color: #333333}
-->
</style>
</head>
    <body>
        <?php
        if ($comum == 'cadLinha'){
            $linhas = getLinha();
            $numLinhas = mysql_num_rows($linhas);
            ?>
        <h1>Linhas cadastradas</h1>
        <br/>
        <form action="/" method="GET">
            <input type="hidden" name="comum" value="cadNewLinha"/>
            <input type="submit" value="Novo" />
        </form>
            <div><br/>
                <table class="relatorio">
                            <thead>
                                    <tr>
                                        <th width="200">Linha</th>
                                        <th width="100">Editar</th>
                                </tr>
                        </thead>
                            <tbody>
                                <?php
                                if ($numLinhas == 0){
                                    echo '<tr><td colspan="2">Nenhuma linha cadastrada</td></tr>';
                                }
                                else {
                                for ($i=0;$i<$numLinhas;$i++)
                                {
                                    $arrayLinhas = mysql_fetch_array($linhas);
                                    mysql_data_seek($arrayLinhas, $i);
                                    echo '<form action="/" method="POST"><tr>';
                                    echo '<input type="hidden" name="operacao" value="alterarLinha" />';
                                    echo '<input type="hidden" name="id" value="'.$arrayLinhas['id'].'" />';
                                    echo '<td><input type="text" name="nome" value="'.$arrayLinhas['nome'].'" size="20" required="required" /></td>';
                                    echo '<td><input type="submit" value="Alterar" /></td>';
                                    echo '</tr></form>';
                                }
                                }
                                ?>
                        </tbody>
                </table>
        </div>
            <?php
        }
        if ($comum == 'cadNewLinha'){
            ?>
        <h1 align="center">Cadastro de Linha</h1>
      <p>&nbsp;</p>
     <form action="/" method="post">
          <input type="hidden" name="operacao" value="cadLinha" />
      <table width="600" border="0" cellspacing="10" cellpadding="0">
        <tr>
        <td width="64"><div align="right"><span class="style1">Nome:</span></div></td>
          <td width="227"><label>
                  <input type="text" name="nome" id="linha" required="required"  size="30" maxlength="99" placeholder="Ex: Linha 156 Sul"/>
          </label></td>
        </tr>
        <tr>
        <td width="64"><div align="right"><span class="style1"></span></div></td>
          <td width="227"><label>
                  <input type="submit" value="Salvar"/>
          </label></td>
        </tr>
      </table>
     </form>
        <?php
        }
        ?>
</body>
</html>